#include <iostream>
#include <pthread.h>
using namespace std;
#include <unistd.h>

void* threadrun(void* args)
{
    int cnt = 5;
    while(cnt)
    {
        cout << "new thread is running: " << cnt << "  " << pthread_self() <<  endl;
        sleep(1);
        cnt--;
    }
    return nullptr;
}


int main() 
{
    pthread_t tid;
    pthread_create(&tid,nullptr,threadrun,nullptr);

    int cnt = 10;
    while(cnt)
    {
        cout << "main thread is running: " << cnt << "  "<< pthread_self() << endl;
        sleep(1);
        cnt--;
    }  
    return 0;
}

